package com.jdy.haoduoai.util;

import android.app.ActivityManager;
import android.app.ActivityManager.RunningServiceInfo;
import android.content.Context;

/**
 * Service utility
 * 
 * @author zp @ 2015-6-11 下午5:03:50
 */
public class ServiceUtils {

  /**
   * 
   * @param context
   * @param serviceClass
   * @return
   */
  public static boolean isMyServiceRunning(Context context,
      Class<?> serviceClass) {
    ActivityManager manager = (ActivityManager) context
        .getSystemService(Context.ACTIVITY_SERVICE);
    for (RunningServiceInfo service : manager
        .getRunningServices(Integer.MAX_VALUE)) {
      if (serviceClass.getName().equals(service.service.getClassName())) {
        return true;
      }
    }
    return false;
  }
}
